import bankAccount


class BankSystem:
    # 初始化
    def __init__(self):
        self.account_list = {123456: bankAccount.BankAccount(123456, '张三', 100),
                             456789: bankAccount.BankAccount(456789, '李四', 100)}

    # 开户
    def create_account(self, account_number, account_holder, initial_balance):
        if account_number not in self.account_list:
            for account in self.account_list.values():
                if account.account_holder == account_holder:
                    return 0
            account = bankAccount.BankAccount(account_number, account_holder, initial_balance)
            self.account_list[account_number] = account
            return 1
        else:
            return 0

    # 获取对象
    def get_account(self, account_number):
        if account_number in self.account_list.keys():
            return self.account_list[account_number]
        else:
            return 0

    # 显示账户信息
    def display_account_info(self, account_number):
        if account_number in self.account_list.keys():
            account = self.account_list[account_number]
            account.display_info()
        else:
            print('账户不存在')
